package com.taobaolite.order_has_items;

import com.taobaolite.item.Item;
import com.taobaolite.order.Order;
import org.hibernate.validator.constraints.Range;

import javax.persistence.*;
import javax.validation.constraints.Min;
import javax.validation.constraints.NotNull;

@Entity
public class OrderHasItems {
    @EmbeddedId
    @NotNull
    @Column(updatable = false,unique = true)
    private OrderHasItemsPK orderHasItemsPK;
    @NotNull
    @Min(value = 0)
    private Long amount;

    public OrderHasItems() {}

    public OrderHasItems(Order order, Item item, Long amount) {
        this.orderHasItemsPK = new OrderHasItemsPK(order,item);
        this.amount = amount;
    }

    public OrderHasItemsPK getOrderHasItemsPK() {
        return orderHasItemsPK;
    }

    public void setOrderHasItemsPK(OrderHasItemsPK orderHasItemsPK) {
        this.orderHasItemsPK = orderHasItemsPK;
    }

    public Long getAmount() {
        return amount;
    }

    public void setAmount(Long amount) {
        this.amount = amount;
    }
}
